<template>
	<view>
		<view class="bd">
			<block v-for="item in listData" v-key="id">
				<view class="item" @click='detail(item)'>
					<view class="item-l">
						<!-- <view class="tit">
							<text>{{item.shop_name}}--{{item.type | typeToText}}</text>
							<text v-if="item.num">【{{item.num}}份】</text>
						</view> -->
						<view class="title">{{item.username}}-{{item.projectParent ? item.projectParent.name : ''}}-{{item.project ? item.project.name : ''}}</view>
						<view class="time content">申请备注：{{item.content}}</view>
						<view class="time">可获积分：{{item.score}}</view>
						<view class="time" v-if="item.state == 0">状态：待审核</view>
						<view class="time" v-if="item.state == 1">状态：已通过</view>
						<view class="time" v-if="item.state == 3">状态：已拒绝</view>
						<view class="time">申请时间：{{item.created_at | time}}</view>
					</view>
					<view class="item-r red">{{item.price}}</view>
				</view>
			</block>
			<uni-load-more :status="loadStatus"></uni-load-more>
		</view>
	</view>
</template>

<script>
	import uniLoadMore from "@/components/uni-load-more/uni-load-more.vue"
	import {
		myLog
	} from '@/api/apply.js';

	import moment from '@/utils/moment';
	import Helper from '@/utils/helper';
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				page: 1,
				onLoading: false,
				nomore: false,
				listData: [],
				loadStatus: 'more'
			}
		},
		onLoad(options) {
			this.$data.type = options.type ? options.type : '';
			this._getData();
		},
		filters: {
			// 时间格式化
			date(val) {
				return moment(val * 1000).format('YYYY-MM-DD')
			},
			// 时间格式化
			time(val) {
				return moment(val * 1000).format('YYYY-MM-DD HH:mm')
			},
			typeToText(type){
				return Helper.typeToText(type);
			}
		},
		methods: {
			_getData: function() {
				var that = this;
				var args = {
					page: this.$data.page,
					num: 15
				}
				this.$data.loadStatus = 'loading'
				this.$http.get(`${myLog}`, {
						...args
					})
					.then(async data => {
						if (data.code == 200) {
							var data = data.data;
							that.listData = that.listData.concat(data);
							that.$data.loadStatus = 'noMore';
						}
					});
			},
			detail(item) {
				var url = '/pages/baocan/result?id=' + item.id;
				this.goto(url);
			}
		},
	}
</script>

<style lang="scss">
	.bd .item {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		padding: 30rpx 30rpx;
		background-color: #fff;
		border-bottom: 1px solid #ececec;
		.content{line-height: 1.4;}
	}

	.bd .item .item-l .tit {
		font-weight: 500;
		margin-bottom: 20rpx;
		font-size: $uni-font-size-base;
	}

	.bd .item .item-l .time {
		font-size: 24rpx;
		color: #999;
	}

	.bd .item .item-r {
		padding-left: 30rpx;
		font-size: $uni-font-size-lg;
		font-weight: 600;
	}

	.green {
		color: #07c160;
	}

	.red {
		color: #FF6600;
	}

	.picker {
		text-align: center;
		background-color: #fff;
		padding: 20rpx 0 40rpx 0;
		border-bottom: 1px solid #f9f9f9;
	}
	.title{
		font-weight: bold;
		margin-bottom: 20rpx;
	}
</style>